using Cysharp.Threading.Tasks;
using Framework.Interface;
using Framework.Singleton;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;

public class HttpManager : Singleton<HttpManager>, IManager
{
    public async UniTask Initialize()
    {
        await UniTask.CompletedTask;
    }

    public void Shutdown()
    {
        
    }

    public async UniTask<string> HttpGet(string url, int timeout = 10)
    {
        UnityWebRequest request = UnityWebRequest.Get(url);
        request.timeout = timeout;
        await request.SendWebRequest();
        if (request.result != UnityWebRequest.Result.Success)
            return request.error;

        return request.downloadHandler.text;
    }
}
